/*
  Copyright © 2010  Vinícius dos Santos Oliveira

      This file is part of Touché.

      Touché is free software: you can redistribute it and/or modify
      it under the terms of the GNU Lesser General Public License as published
      by the Free Software Foundation, either version 3 of the License, or
      (at your option) any later version.

      This program is distributed in the hope that it will be useful,
      but WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      GNU Lesser General Public License for more details.

      You should have received a copy of the GNU Lesser General Public License
      along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */

#ifndef SLIDERITEM_H
#define SLIDERITEM_H

#include <QGraphicsSvgItem>

class SliderItem : public QGraphicsSvgItem
{
    Q_OBJECT

    Qt::Orientation orientation;
    QGraphicsSvgItem *button;
    unsigned m_minimum, m_maximum, m_current;

protected:
    virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
    virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
    virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
    virtual void wheelEvent(QGraphicsSceneWheelEvent *event);

public:
    SliderItem(const QString &fileName, const QString &buttonFileName,
                    Qt::Orientation orientation = Qt::Vertical, QGraphicsItem *parentItem = NULL);
    int minimum() const { return m_minimum; }
    void setMinimum(unsigned minimum);
    int maximum() const { return m_maximum; }
    void setMaximum(unsigned maximum);
    unsigned value() const { return m_current; }

public slots:
    void setValue(unsigned value);

signals:
    void rangeChanged(unsigned min, unsigned max);
    void sliderPressed();
    void sliderReleased();
    void valueChanged(unsigned value);
};

#endif // SLIDERITEM_H
